<?php


require_once __DIR__ . '/vendor/autoload.php';
use PhpAmqpLib\Connection\AMQPStreamConnection;

$connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();
 

$channel->exchange_declare('direct_logs', 'direct', false, false, false);
list($queue_name, ,) = $channel->queue_declare("", false, false, true, false);

$bingding_key  ='keys';
$channel->queue_bind($queue_name, 'direct_logs', $bingding_key);
$callback = function($msg){
  	 echo ' [x] ',$msg->delivery_info['routing_key'], ':', $msg->body, "\n";
  	 echo $msg->delivery_info['delivery_tag'];

  	 $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);

};


$channel->basic_consume($queue_name, '', false, true, false, false, $callback);

while(count($channel->callbacks)) {
    $channel->wait();
}

$channel->close();
$connection->close();